/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: ComCfg.c
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: Com
*
* Generation Time: 2025-02-04 15:31:15
*
*******************************************************************************/

/** HEADER FILES **/
#include "ComCfg.h"


/** MACRO DEFINITION **/


/** TYPEDEF DEFINITION **/


/** LOCAL DATA DECLARATION **/
const Com_SignalConfigType Com_TxSignal[ComConf_Tx_SignalId_Max];
const Com_SignalConfigType Com_RxSignal[ComConf_Rx_SignalId_Max];


/** LOCAL FUNCTION DECLARATION **/

Std_ReturnType IPDU_E2EProtect_Channel1_Qsar_Qsar_Can3(
    PduIdType TxPduId, 
    PduInfoType* PduInfoPtr
);
Std_ReturnType IPDU_E2EProtect_Channel1_Qsar_Qsar_Can2(
    PduIdType TxPduId, 
    PduInfoType* PduInfoPtr
);

Std_ReturnType IPDU_E2ECheck_Channel1_Other_Other_Can2(
    PduIdType RxPduId, 
    PduInfoType* PduInfoPtr
);
/*******************************************************************************
* -Name            IPDU_E2ECheck_Channel1_Other_Other_Can2
* -Brief           Callout for usage with E2E
* -Details         None
* -Param[in]       RxPduId: Source id for routing    
* -Param[in]       PduInfoPtr: PduInfo
* -Return          E_OK: Request accomplished successful
*                  E_NOT_OK:
*******************************************************************************/
Std_ReturnType IPDU_E2ECheck_Channel1_Other_Other_Can2(
    PduIdType RxPduId, 
    PduInfoType* PduInfoPtr
)
{
    Std_ReturnType retVal = E_NOT_OK;
    /* At first run, instantiate the structures and set the init values*/ 
    E2E_P01ConfigType settings = 
    {
        48u, /* CounterOffset */
        56u, /* CRCOffset */
        514u, /* DataID */
        0u, /* DataIDNibbleOffset */
        E2E_P01_DATAID_BOTH, /* DataIDMode */
        7u, /* DataLength */
        2u, /* MaxDeltaCounterInit */
        4u, /* MaxNoNewOrRepeatedData */
        3u /* SyncCounterInit */
    };
    static E2E_P01CheckStateType state = 
    {
        0x00, /* LastValidCounter */
        2u, /* MaxDeltaCounter */
        RESET, /* WaitForFirstData */
        RESET, /* NewDataAvailable */
        0x00, /* LostData */
        E2E_P01STATUS_NONEWDATA, /* Status */
        0x00, /* SyncCounter */
        0x00 /* NoNewOrRepeatedDataCounter */
    };
    
    retVal = E2E_P01Check((E2E_P01ConfigType*)&settings, (E2E_P01ProtectStateType*)&state, PduInfoPtr->SduDataPtr);

    return(retVal);
}

/** LOCAL DATA **/
static uint8 ComConf_ComTxPdu_Channel1_Qsar_Qsar_Can4[8] = {0x00}; 
static uint8 ComConf_ComTxPdu_Channel1_Qsar_Qsar_Can3[8] = {0x00}; 
static uint8 ComConf_ComTxPdu_Channel1_Qsar_Qsar_Can2[8] = {0x00}; 
static uint8 ComConf_ComTxPdu_Channel1_Qsar_Qsar_Can1[8] = {0x00}; 

static uint8 ComConf_ComRxPdu_Channel1_Other_Other_Can3[8] = {0x00}; 
static uint8 ComConf_ComRxPdu_Channel1_Other_Other_Can2[8] = {0x00}; 
static uint8 ComConf_ComRxPdu_Channel1_Other_Other_Can1[8] = {0x00}; 

uint8 Com_TxSignalBuffer[19] = {0x00};
uint8 Com_RxSignalBuffer[12] = {0x00};

uint8 Com_TxPduUpdateBitBuffer = 0x00;
uint8 Com_RxPduUpdateBitBuffer = 0x00;

uint8 Com_TxSignalUpdateBitBuffer[2] = {0x00};
uint8 Com_RxSignalUpdateBitBuffer[2] = {0x00};

const Com_SignalConfigType Com_TxSignal[ComConf_Tx_SignalId_Max] = 
{
    /*Notification, ComTimeoutNotification, bitPosition, bitSize, signalLength,  signalInitValue, comHandleId, signalType, signalEndianness, signalBufferPtr */
    {NULL_PTR, NULL_PTR, 37u, 2u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[0]}, /* Channel1_Qsar_Qsar_Can3_Qsar_Can3_Yaya */
    {NULL_PTR, NULL_PTR, 48u, 4u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[1]}, /* Channel1_Qsar_Qsar_Can3_Qsar_Can3_RollingCounter */
    {NULL_PTR, NULL_PTR, 17u, 14u, 2u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[2]}, /* Channel1_Qsar_Qsar_Can3_Qsar_Can3_Haha */
    {NULL_PTR, NULL_PTR, 56u, 8u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_LITTLE_ENDIAN, (uint8*)&Com_TxSignalBuffer[4]}, /* Channel1_Qsar_Qsar_Can3_Qsar_Can3_Checksum */
    {NULL_PTR, NULL_PTR, 48u, 4u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[5]}, /* Channel1_Qsar_Qsar_Can2_Qsar_Can2_RollingCounter */
    {NULL_PTR, NULL_PTR, 56u, 8u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[6]}, /* Channel1_Qsar_Qsar_Can2_Qsar_Can2_Checksum */
    {NULL_PTR, NULL_PTR, 34u, 2u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[7]}, /* Channel1_Qsar_Qsar_Can2_Qsar_Can2_SignalC */
    {NULL_PTR, NULL_PTR, 40u, 8u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[8]}, /* Channel1_Qsar_Qsar_Can2_Qsar_Can2_SignalB */
    {NULL_PTR, NULL_PTR, 26u, 28u, 4u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[9]}, /* Channel1_Qsar_Qsar_Can2_Qsar_Can2_SignalA */
    {NULL_PTR, NULL_PTR, 55u, 3u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_LITTLE_ENDIAN, (uint8*)&Com_TxSignalBuffer[13]}, /* Channel1_Qsar_Qsar_Can1_Qsar_Can1_SignalD_Intel */
    {NULL_PTR, NULL_PTR, 60u, 3u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[14]}, /* Channel1_Qsar_Qsar_Can1_Qsar_Can1_SignalC_Motorola */
    {NULL_PTR, NULL_PTR, 31u, 10u, 2u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_LITTLE_ENDIAN, (uint8*)&Com_TxSignalBuffer[15]}, /* Channel1_Qsar_Qsar_Can1_Qsar_Can1_SignalB_Intel */
    {NULL_PTR, NULL_PTR, 23u, 10u, 2u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_TxSignalBuffer[17]}, /* Channel1_Qsar_Qsar_Can1_Qsar_Can1_SignalA_Motorola */
};


const Com_SignalConfigType Com_RxSignal[ComConf_Rx_SignalId_Max] = 
{
    /*Notification, ComTimeoutNotification, bitPosition, bitSize, signalLength,  signalInitValue, comHandleId, signalType, signalEndianness, signalBufferPtr */
    {NULL_PTR, NULL_PTR, 56u, 8u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_RxSignalBuffer[0]}, /* Channel1_Other_Other_Can2_Other_Can2_Checksum */
    {NULL_PTR, NULL_PTR, 48u, 4u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_RxSignalBuffer[1]}, /* Channel1_Other_Other_Can2_Ohter_Can2_RollingCounter */
    {NULL_PTR, NULL_PTR, 26u, 2u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_RxSignalBuffer[2]}, /* Channel1_Other_Other_Can2_Other_Can2_SignalB */
    {NULL_PTR, NULL_PTR, 4u, 3u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_RxSignalBuffer[3]}, /* Channel1_Other_Other_Can2_Other_Can2_SignalA */
    {NULL_PTR, NULL_PTR, 59u, 5u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_LITTLE_ENDIAN, (uint8*)&Com_RxSignalBuffer[4]}, /* Channel1_Other_Other_Can1_Other_Can1_SignalD_Intel */
    {NULL_PTR, NULL_PTR, 51u, 5u, 1u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_RxSignalBuffer[5]}, /* Channel1_Other_Other_Can1_Other_Can1_SignalC_Motorala */
    {NULL_PTR, NULL_PTR, 39u, 10u, 2u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_LITTLE_ENDIAN, (uint8*)&Com_RxSignalBuffer[6]}, /* Channel1_Other_Other_Can1_Other_Can1_SignalB_Intel */
    {NULL_PTR, NULL_PTR, 26u, 25u, 4u,  0u, 0u, COM_SIGNAL_TYPE_UINT8, COM_SIGNAL_BIG_ENDIAN, (uint8*)&Com_RxSignalBuffer[8]}, /* Channel1_Other_Other_Can1_Other_Can1_SignalA_Motorala */
};


const ComIPduType Com_TxPduConfig[ComConf_ComTxPduCfg_Pdu_Max] = 
{
    {NULL_PTR, (Com_SignalConfigType*)&Com_TxSignal[ComConf_Tx_SignalId_Channel1_Qsar_Qsar_Can4_First], ComConf_Tx_SignalId_Channel1_Qsar_Qsar_Can4_Max, ComConf_ComTxPduCfg_Pdu_Channel1_Qsar_Qsar_Can4, ComConf_ComTxPdu_Channel1_Qsar_Qsar_Can4, COM_IPDU_TYPE_NORMAL, {0x00u, 0x01u, COM_IPDU_TX_CLEAR_UPDATE_BIT_TRANSMIT, {100u, 0u, COM_TX_MODE_PERIODIC}}}, 
    {IPDU_E2EProtect_Channel1_Qsar_Qsar_Can3, (Com_SignalConfigType*)&Com_TxSignal[ComConf_Tx_SignalId_Channel1_Qsar_Qsar_Can3_First], ComConf_Tx_SignalId_Channel1_Qsar_Qsar_Can3_Max, ComConf_ComTxPduCfg_Pdu_Channel1_Qsar_Qsar_Can3, ComConf_ComTxPdu_Channel1_Qsar_Qsar_Can3, COM_IPDU_TYPE_NORMAL, {0x00u, 0x01u, COM_IPDU_TX_CLEAR_UPDATE_BIT_TRANSMIT, {50u, 0u, COM_TX_MODE_PERIODIC}}}, 
    {IPDU_E2EProtect_Channel1_Qsar_Qsar_Can2, (Com_SignalConfigType*)&Com_TxSignal[ComConf_Tx_SignalId_Channel1_Qsar_Qsar_Can2_First], ComConf_Tx_SignalId_Channel1_Qsar_Qsar_Can2_Max, ComConf_ComTxPduCfg_Pdu_Channel1_Qsar_Qsar_Can2, ComConf_ComTxPdu_Channel1_Qsar_Qsar_Can2, COM_IPDU_TYPE_NORMAL, {0x00u, 0x01u, COM_IPDU_TX_CLEAR_UPDATE_BIT_TRANSMIT, {20u, 0u, COM_TX_MODE_PERIODIC}}}, 
    {NULL_PTR, (Com_SignalConfigType*)&Com_TxSignal[ComConf_Tx_SignalId_Channel1_Qsar_Qsar_Can1_First], ComConf_Tx_SignalId_Channel1_Qsar_Qsar_Can1_Max, ComConf_ComTxPduCfg_Pdu_Channel1_Qsar_Qsar_Can1, ComConf_ComTxPdu_Channel1_Qsar_Qsar_Can1, COM_IPDU_TYPE_NORMAL, {0x00u, 0x01u, COM_IPDU_TX_CLEAR_UPDATE_BIT_TRANSMIT, {110u, 0u, COM_TX_MODE_PERIODIC}}}, 
};


const ComIPduType Com_RxPduConfig[ComConf_ComRxPduCfg_Pdu_Max] = 
{
    {NULL_PTR, (Com_SignalConfigType*)&Com_RxSignal[ComConf_Rx_SignalId_Channel1_Other_Other_Can3_First], ComConf_Rx_SignalId_Channel1_Other_Other_Can3_Max, ComConf_ComRxPduCfg_Pdu_Channel1_Other_Other_Can3, ComConf_ComRxPdu_Channel1_Other_Other_Can3, COM_IPDU_TYPE_NORMAL, {0x00u}}, 
    {IPDU_E2ECheck_Channel1_Other_Other_Can2, (Com_SignalConfigType*)&Com_RxSignal[ComConf_Rx_SignalId_Channel1_Other_Other_Can2_First], ComConf_Rx_SignalId_Channel1_Other_Other_Can2_Max, ComConf_ComRxPduCfg_Pdu_Channel1_Other_Other_Can2, ComConf_ComRxPdu_Channel1_Other_Other_Can2, COM_IPDU_TYPE_NORMAL, {0x00u}}, 
    {NULL_PTR, (Com_SignalConfigType*)&Com_RxSignal[ComConf_Rx_SignalId_Channel1_Other_Other_Can1_First], ComConf_Rx_SignalId_Channel1_Other_Other_Can1_Max, ComConf_ComRxPduCfg_Pdu_Channel1_Other_Other_Can1, ComConf_ComRxPdu_Channel1_Other_Other_Can1, COM_IPDU_TYPE_NORMAL, {0x00u}}, 
};

/** LOCAL FUNCTION **/

/*******************************************************************************
* -Name            IPDU_E2EProtect_Channel1_Qsar_Qsar_Can3
* -Brief           Callout for usage with E2E
* -Details         None
* -Param[in]       TxPduId: Source id for routing    
* -Param[in]       PduInfoPtr: PduInfo
* -Return          E_OK: Request accomplished successful
*                  E_NOT_OK:
*******************************************************************************/
Std_ReturnType IPDU_E2EProtect_Channel1_Qsar_Qsar_Can3(
    PduIdType TxPduId, 
    PduInfoType* PduInfoPtr
)
{
    Std_ReturnType retVal = E_OK;
    
    /* At first run, instantiate the structures and set the init Values*/ 
    E2E_P01ConfigType settings = 
    {
        48u, /* CounterOffset */
        56u, /* CRCOffset */
        259u, /* DataID */
        0u, /* DataIDNibbleOffset */
        E2E_P01_DATAID_BOTH, /* DataIDMode */
        7u, /* DataLength */
        1u, /* MaxDeltaCounterInit */
        4u, /* MaxNoNewOrRepeatedData */
        3u /* SyncCounterInit */
    };

    static E2E_P01ProtectStateType state = {0}; 

    E2E_P01Protect((E2E_P01ConfigType*)&settings, (E2E_P01ProtectStateType*)&state, PduInfoPtr->SduDataPtr);

    return(retVal);
}
/*******************************************************************************
* -Name            IPDU_E2EProtect_Channel1_Qsar_Qsar_Can2
* -Brief           Callout for usage with E2E
* -Details         None
* -Param[in]       TxPduId: Source id for routing    
* -Param[in]       PduInfoPtr: PduInfo
* -Return          E_OK: Request accomplished successful
*                  E_NOT_OK:
*******************************************************************************/
Std_ReturnType IPDU_E2EProtect_Channel1_Qsar_Qsar_Can2(
    PduIdType TxPduId, 
    PduInfoType* PduInfoPtr
)
{
    Std_ReturnType retVal = E_OK;
    
    /* At first run, instantiate the structures and set the init Values*/ 
    E2E_P01ConfigType settings = 
    {
        48u, /* CounterOffset */
        56u, /* CRCOffset */
        258u, /* DataID */
        0u, /* DataIDNibbleOffset */
        E2E_P01_DATAID_BOTH, /* DataIDMode */
        7u, /* DataLength */
        1u, /* MaxDeltaCounterInit */
        4u, /* MaxNoNewOrRepeatedData */
        3u /* SyncCounterInit */
    };

    static E2E_P01ProtectStateType state = {0}; 

    E2E_P01Protect((E2E_P01ConfigType*)&settings, (E2E_P01ProtectStateType*)&state, PduInfoPtr->SduDataPtr);

    return(retVal);
}
